// 额外的 UI 交互逻辑
document.addEventListener('DOMContentLoaded', () => {
    // 检查是否在通话页面且已登录
    if (window.location.pathname === '/call') {
        const userName = localStorage.getItem('userName');
        if (!userName) {
            window.location.href = '/';
            return;
        }
    }
    
    // 添加键盘快捷键
    document.addEventListener('keydown', (e) => {
        // ESC 键挂断通话
        if (e.key === 'Escape' && webrtcClient && webrtcClient.currentCall) {
            webrtcClient.hangup();
        }
        
        // 空格键切换音频
        if (e.key === ' ' && e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA') {
            e.preventDefault();
            if (webrtcClient) {
                webrtcClient.toggleAudio();
            }
        }
    });
});